package com.shiguiwu.springmybatis.designpattern.dutychain.scene;

import lombok.extern.slf4j.Slf4j;

/**
 * @description: 行酒令
 * @author: stone
 * @date: Created by 2022/11/7 21:49
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.dutychain.scene
 * todo 差一个击鼓结束的标识，不然一直传花
 */
@Slf4j
public abstract class Player {

    //protected boolean isHaveFlower = false;

    public static  volatile boolean isStop = false;

    protected String name;

    private Player next;

    public void setNext(Player next) {
        this.next = next;
    }

    public Player(String name) {
        this.name = name;
    }

    public Player(String name, Player next) {
        this.next = next;
        this.name = name;
    }


    public abstract void handle() throws Exception;

    public void next() throws Exception{
        if (this.next == null) {
            log.info("{} ,行酒令结束。。。。。。。。", this.name);
        }
        else {
            next.handle();
        }
    }
}
